# conding = utf-8
import random


def get_num(log_path):
    with open(log_path, 'r') as f:
        for line in f.readlines():
            list_ball = line.strip(',').split(',')
        return list_ball


times = 1
print('----------------------------------')
print('--------双色球智能选择程序--------')
print('----------------------------------')
while times <= 5:
    ball_list = []
    # 红球1
    red_ball_list_one = get_num('ball/red_ball_1.log')
    red_ball_one = red_ball_list_one[random.randint(0, len(red_ball_list_one) - 1)]
    ball_list.append(red_ball_one)

    # 红球2
    red_ball_list_two = get_num('ball/red_ball_2.log')
    for i in red_ball_list_two:
        if i in ball_list:
            red_ball_list_two.remove(i)
    red_ball_two = red_ball_list_two[random.randint(0, len(red_ball_list_two) - 1)]
    ball_list.append(red_ball_two)

    # 红球3
    red_ball_list_three = get_num('ball/red_ball_3.log')
    for i in red_ball_list_three:
        if i in ball_list:
            red_ball_list_three.remove(i)
    red_ball_three = red_ball_list_three[random.randint(0, len(red_ball_list_three) - 1)]
    ball_list.append(red_ball_three)

    # 红球4
    red_ball_list_four = get_num('ball/red_ball_4.log')
    for i in red_ball_list_four:
        if i in ball_list:
            red_ball_list_four.remove(i)
    red_ball_four = red_ball_list_four[random.randint(0, len(red_ball_list_four) - 1)]
    ball_list.append(red_ball_four)

    # 红球5
    red_ball_list_five = get_num('ball/red_ball_5.log')
    for i in red_ball_list_five:
        if i in ball_list:
            red_ball_list_five.remove(i)
    red_ball_five = red_ball_list_five[random.randint(0, len(red_ball_list_five) - 1)]
    ball_list.append(red_ball_five)

    # 红球6
    red_ball_list_six = get_num('ball/red_ball_6.log')
    for i in red_ball_list_six:
        if i in ball_list:
            red_ball_list_six.remove(i)
    red_ball_six = red_ball_list_six[random.randint(0, len(red_ball_list_six) - 1)]
    ball_list.append(red_ball_six)
    b = []
    for a in ball_list:
        if a.startswith('0'):
            a = int(a[1])
            b.append(a)
        else:
            b.append(int(a))
    b.sort()
    ball_list = []
    for bb in b:
        if bb < 10:
            bb = '0' + str(bb)
            ball_list.append(bb)
        else:
            ball_list.append(str(bb))
    # 篮球
    blue_ball_list = get_num('ball/blue_ball.log')
    blue_ball = blue_ball_list[random.randint(0, len(blue_ball_list) - 1)]
    ball_list.append(blue_ball)
    times += 1
    print('红:  %s %s %s %s %s %s    篮:  %s' % (
        ball_list[0], ball_list[1], ball_list[2], ball_list[3], ball_list[4], ball_list[5], ball_list[6]))
print('----------------------------------')
